/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package examplesocket;

import java.util.Enumeration;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @author Administrator
 */
public class Group {
    ConcurrentHashMap <String ,User> users;
    Group()
    {
        ConcurrentHashMap <String ,User> users = new ConcurrentHashMap();
    }
    boolean isAbsent(String username) //return false if the users with this name is present in the map
    {
        if(users.get(username) != null)
            return false;
        else
            return true;
    }
    boolean addNewMember(User newU)
    {
        if(users.get(newU.getName()) != null)
            return false;
        else
        {
            users.put(newU.getName(), newU);
            return true;
        }
    }
    boolean removeMember(User delU)
    {
        if(users.size() <= 2)
            return false;
        else if(users.get(delU.getName()) != null)
        {
            users.remove(delU.getName());
        }
        return true;
    }
    Enumeration<String> listOfKey()
    {
        return users.keys();
    }
}
